#!/bin/bash
#
#

#
#
PID=$1;

# Monitor for 10 hours
TIMESPAN=7200
INDEX=0

while true
do
        if [ $((TIMESPAN)) -lt 0 ]
        then
                echo "Programe exit...";
                exit 1;
        fi

        if [ $((TIMESPAN%12)) -eq 0 ]
        then
                : $((INDEX++))
                touch $0.${PID}.${INDEX}
        fi

        date '+[%Y-%m-%d %H:%M:%S.0000]' >> $0.${PID}.${INDEX}
        procstack -F $PID >> $0.${PID}.${INDEX}
        sleep 5;

        : $((--TIMESPAN));
done
exit 0
